//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using Microsoft.Practices.CompositeWeb.Interfaces;
using Mindscape.BackgroundMotion.Core;

namespace Mindscape.BackgroundMotion.Website
{
  /// <summary>
  /// A implementation of a Service Broker which will host a collection of services injected by the Composite Web block
  /// </summary>
  public sealed class CabServiceBroker : IServiceBroker
  {
    private readonly IServiceCollection _serviceCollection;

    /// <summary>
    /// Initializes the broker with a collection of services constructed by the Composite Web block
    /// </summary>
    /// <param name="serviceCollection"></param>
    public CabServiceBroker(IServiceCollection serviceCollection)
    {
      _serviceCollection = serviceCollection;
    }

    /// <summary>
    /// Gets a stored service from the broker
    /// </summary>
    /// <returns>The service which adheres to the generic type requested</returns>
    public T Get<T>()
    {
      return _serviceCollection.Get<T>();
    }
  }
}